var $j=jQuery.noConflict();
var subscriptionErrors = false;
$j(document).ready(function(){
// Contact us Portion Starts
	$j(".con-req").focus(function(){
			$j(this).next('span').attr('style','display:inline');
	});
	$j(".con-req").blur(function(){
		$j(this).next('span').attr('style','display:none');
		if($j(this).isEmpty())
		{
			$j(this).next('span').attr('style','display:inline');
			$j(this).next('span').css('background','#F8E48B url(images/bg-span-hint-kindagood.gif) no-repeat 0px 0px');
			$j(this).addClass('denied');
			
		}
		else if(!$j(this).emailCheck() && $j(this).attr('id') == 'contactus_email')
		{
			$j(this).next('span').attr('style','display:inline');
			$j(this).next('span').css('background','#F8E48B url(images/bg-span-hint-kindagood.gif) no-repeat 0px 0px');
			$j(this).addClass('denied');
		}
		else if($j(this).isEmpty() && $j(this).attr('id') == 'subject')
		{
			$j(this).next('span').attr('style','display:inline');
			$j(this).next('span').css('background','#F8E48B url(images/bg-span-hint-kindagood.gif) no-repeat 0px 0px');
			$j(this).addClass('denied');
		}
		else
		{
			$j(this).next('span').attr('style','display:inline');
			$j(this).next('span').css('background','#9fd680 url(images/bg-span-hint-welldone.gif) no-repeat 0px 0px');
			$j(this).removeClass('denied');
		}
	});
//Contact us Portion Ends

});
// Contact us Portion Starts
function contactus(formID)
{
	$j(".con-req").blur();
	if($j(".denied").length == 0){
		var data=$j('#'+formID).serializeArray();
		$j(".contactus-block").css('height','100px');
		$j(".contactus-block").html('<div style="width:400px; margin-top:20px; text-align:center;"><img src="images/ajax-loader.gif" border="0"></div>');
		$j.ajax({
				type:'POST',
				url:'requests.php',
				data: data,
				dataType:'json',
				success:function(jData){
					if(jData.flag == 1)
					{
						
						$j("#con-area").html('<div style="width:400px; margin-top:20px; text-align:left;">'+jData.msg+'</div>');
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					$j(".contactus-block").html("Some server error occoured. Please report to system administrator.</div>");
				}
		});
	}
}
//Contact us Portion Ends


function AddToBasket()
{						
		var frmID='#prdt';
		
		var paramsObj = $j(frmID).serializeArray();				
		$j.ajax({
				type: "POST",
				url: 'shopping_cart_process.php',
				data: paramsObj,
				dataType: 'json',				
				success: function(jData){										 
					if(jData.flag == 1)
					{
						 $j('#response').html(jData.text);				 						
					}
					else if(jData.flag == 0)
					{
						window.location.href = jData.text;	
					}
				}

		});

}

function EmptyBasket()
{						
			
		var params={
				'action'	: 'empty_basket',
				'IsProcess'	: 'Y'
				};
				
		$j.ajax({
				type: "POST",
				url: 'shopping_cart.php',
				data: params,
				dataType: 'html',				
				success: function(Data){										 					
					$j('#ShoppingCartDisplayID').html(Data);		
				}

		});

}


function ReCalculateQuantity(frmID,is_checkout)
{					
		
		var params={
				'action'	: 'recalculate_quantity',
				'IsProcess'	: 'Y',
				'is_checkout'	: is_checkout
				};
				
		var paramsObj = $j(frmID).serializeArray();	
		$j.each(paramsObj, function(i, field){
			params[field.name] = field.value;			
		});		
		
		$j.ajax({
				type: "POST",
				url: 'shopping_cart_process.php',
				data: params,
				dataType: 'json',				
				success: function(jData){						
					if(jData.flag == 1)
					{
						 ShoppingCartDisplay();		 						
					}
					else if(jData.flag == 2)
					{
						window.location.href = jData.text;	
					}	
							
				}

		});

}



function ShoppingCartDisplay()
{						
		
		var params={				
				'IsProcess'	: 'Y'
				};
				
		$j.ajax({
				type: "POST",
				url: 'shopping_cart.php',
				data: params,
				dataType: 'html',				
				success: function(Data){										 					
					$j('#ShoppingCartDisplayID').html(Data);		
				}

		});

}

function CheckOutValidation(frmID)
{								
		$j("ErrMsgDisplay").html("<img src='images/indicator.gif' border='0'>");
		var paramsObj = $j(frmID).serializeArray();				
		
		$j.ajax({
				type: "POST",
				url: 'checkout_validation_process.php',
				data: paramsObj,
				dataType: 'json',				
				success: function(jData){						
					if(jData.flag == 1)
					{
						 $j('#ErrMsgDisplay').html(jData.text); 						
					}
					else if(jData.flag == 2)
					{
						$j(frmID).submit();
					}	
							
				}

		});

}

function ConfirmOrder()
{								
		$j.ajax({
				type: "POST",
				url: 'checkout_confirm_process.php',
				data: '',
				dataType: 'json',				
				success: function(jData){	
					window.location.href = jData.url;	
					//$j('#mid_pannel').html(jData.mgs);
				}

		});

}
function ConfirmOrder_pay()
{								
		$j.ajax({
				type: "POST",
				url: 'checkout_confirm_process.php?from=pay_now',
				data: '',
				dataType: 'json',				
				success: function(jData){	
					window.location.href = jData.url;													
				}

		});

}




function RemoveAProduct(cart_id)
{					
		
		
	if(confirm("Delete This Item?!")) 
	{		
		var params={
				'action'	: 'remove_a_product',
				'IsProcess'	: 'Y',
				'shopping_cart_id'	: cart_id
				};

	
		$j.ajax({
				type: "POST",
				url: 'shopping_cart_process.php',
				data: params,
				dataType: 'json',				
				success: function(jData){						

					if(jData.flag == 1)
					{
						 ShoppingCartDisplay();		 						
					}
					else if(jData.flag == 2)
					{
						window.location.href = jData.text;	
					}	
							
				}

		});
	
	
	
	
	}
	

}




